#include "qpropertycorecreator.h"

#include "qproperty.h"

#include "qeditorfactory.h"


#include "../../lib/shared/qobjecthost.h"

QProperty* QPropertyCoreCreator::createProperty(QString name,QString className)
{
    QProperty *pro=NULL;
    QString type=propertyType(name,className);
    int len=type.size();
    switch(len)
    {
    case 12:
        if(type=="QIntProperty")pro=new QIntProperty(name,NULL);
        break;
    case 13:
        if(type=="QRectProperty")pro=new QRectProperty(name,NULL);
        else if(type=="QSizeProperty")pro=new QSizeProperty(name,NULL);
        else if(type=="QByteProperty")pro=new QByteProperty(name,NULL);
        else if(type=="QBoolProperty")pro=new QBoolProperty(name,NULL);
        else if(type=="QFontProperty")pro=new QFontProperty(name,NULL);
        else if(type=="QEnumProperty")pro=new QEnumProperty(name,NULL);
        else if(type=="QTimeProperty")pro=new QTimeProperty(name,NULL);
        else if(type=="QDateProperty")pro=new QDateProperty(name,NULL);
        break;
    case 14:
        if(type=="QFloatProperty")pro=new QFloatProperty(name,NULL);
        else if(type=="QColorProperty")pro=new QColorProperty(name,NULL);
        else if(type=="QImageProperty")pro=new QImageProperty(name,NULL);
        break;
    case 15:
        if(type=="QCursorProperty")pro=new QCursorProperty(name,NULL);
        else if(type=="QScriptProperty")pro=new QScriptProperty(name,NULL);
        else if(type=="QBorderProperty")pro=new QBorderProperty(name,NULL);
        break;
    case 16:
        if(type=="QPaddingProperty")pro=new QPaddingProperty(name,NULL);
        break;
    case 17:
        if(type=="QDateTimeProperty")pro=new QDateTimeProperty(name,NULL);
        break;
    case 19:
        if(type=="QComboItemsProperty")pro=new QComboItemsProperty(name,NULL);
        break;
    case 20:
        if(type=="QMemeryValueProperty")pro=new QMemeryValueProperty(name,NULL);
        break;
    }
    return pro;
}

QWidget* QPropertyCoreCreator::createEditor(QWidget *parent, QProperty *property)
{
    QString type=property->metaObject()->className();
    QWidget *wid=NULL;
    int len=type.size();
    switch(len)
    {
    case 12:
        if(type=="QIntProperty")wid=new QSpinBoxEditor(property,parent);
        break;
    case 13:
        if(type=="QRectProperty")wid=new QLabelEditor(property,parent);
        else if(type=="QSizeProperty")wid=new QLabelEditor(property,parent);
        else if(type=="QByteProperty")
        {
            if(property->name()=="objectName")
            {
                wid=new QNameLineEditor(property,parent);
            }
            else
            {
                wid=new QByteEditor(property,parent);
            }
        }
        else if(type=="QBoolProperty")wid=new QBoolEditor(property,parent);
        else if(type=="QFontProperty")wid=new QFontEditor(property,parent);
        else if(type=="QEnumProperty")wid=new QEnumEditor(property,parent);
        else if(type=="QTimeProperty")wid=new QTimeEditor(property,parent);
        else if(type=="QDateProperty")wid=new QDateEditor(property,parent);
        break;
    case 14:
        if(type=="QFloatProperty")wid=new QDoubleSpinBoxEditor(property,parent);
        else if(type=="QColorProperty")wid=new QColorEditor(property,parent);
        else if(type=="QImageProperty")wid=new QImageEditor(property,parent);
        break;
    case 15:
        if(type=="QCursorProperty")wid=new QCursorEditor(property,parent);
        else if(type=="QScriptProperty")wid=new QScriptEditor(property,parent);
        else if(type=="QBorderProperty")wid=new QBorderEditor(property,parent);
        break;
    case 16:
        if(type=="QPaddingProperty")wid=new QPaddingEditor(property,parent);
        break;
    case 17:
        if(type=="QDateTimeProperty")wid=new QDateTimeEditor(property,parent);
        break;
    case 19:
        if(type=="QFontFamilyProperty")wid=new QFontFamilyEditor(property,parent);
        else if(type=="QComboItemsProperty")wid=new QComboItemEditor(property,parent);
        break;
    case 20:
        if(type=="QMemeryValueProperty")wid=new QMemeryValueEditor(property,parent);
        break;
    }
    return wid;
}
